<?php

/**
 * Product form base class.
 *
 * @method Product getObject() Returns the current form's model object
 *
 * @package    corpon
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseProductForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_product'       => new sfWidgetFormInputHidden(),
      'name'             => new sfWidgetFormInputText(),
      'subtitle'         => new sfWidgetFormInputText(),
      'description'      => new sfWidgetFormTextarea(),
      'increment'        => new sfWidgetFormInputText(),
      'status'           => new sfWidgetFormInputCheckbox(),
      'highlight'        => new sfWidgetFormInputCheckbox(),
      'price'            => new sfWidgetFormInputText(),
      'discount'         => new sfWidgetFormInputText(),
      'discounted_price' => new sfWidgetFormInputText(),
      'photo1'           => new sfWidgetFormInputText(),
      'photo2'           => new sfWidgetFormInputText(),
      'photo3'           => new sfWidgetFormInputText(),
      'start_date'       => new sfWidgetFormDate(),
      'end_date'         => new sfWidgetFormDate(),
      'created_at'       => new sfWidgetFormDateTime(),
      'id_account'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Account'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id_product'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_product')), 'empty_value' => $this->getObject()->get('id_product'), 'required' => false)),
      'name'             => new sfValidatorString(array('max_length' => 50)),
      'subtitle'         => new sfValidatorString(array('max_length' => 200)),
      'description'      => new sfValidatorString(array('max_length' => 500)),
      'increment'        => new sfValidatorInteger(),
      'status'           => new sfValidatorBoolean(array('required' => false)),
      'highlight'        => new sfValidatorBoolean(array('required' => false)),
      'price'            => new sfValidatorNumber(),
      'discount'         => new sfValidatorNumber(),
      'discounted_price' => new sfValidatorNumber(),
      'photo1'           => new sfValidatorString(array('max_length' => 75)),
      'photo2'           => new sfValidatorString(array('max_length' => 75, 'required' => false)),
      'photo3'           => new sfValidatorString(array('max_length' => 75, 'required' => false)),
      'start_date'       => new sfValidatorDate(array('required' => false)),
      'end_date'         => new sfValidatorDate(array('required' => false)),
      'created_at'       => new sfValidatorDateTime(),
      'id_account'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Account'))),
    ));

    $this->widgetSchema->setNameFormat('product[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Product';
  }

}
